/**
 * Created by Administrator on 15-3-24.
 */

 var save_type = getQueryString("type");
//发布课件
function publishLessonFn(){
    $.ajax({
        url: API_URL+'curriculum/saveCurriculum?agentid='+agentid+'&type='+save_type,
        type: 'POST',
        dataType: "JSON",
        async: false,
        data:$('#publishVideo').serialize(),
        success: function (obj){
            console.log(obj)
            if (obj.status.code == 0) {
                window.location='status_detial.html?openid='+openid+'&detialId='+obj.basedata.id+'&user_status='+user_status;
                //window.location = 'publish_video.html?openid='+openid+'&detialId='+detialId;
            }else{
                alert('服务错误');
            }
        },
        error: function (data){
            console.log("服务器异常!");
        }
    });
}

$(function(){
    $('.publish_video').on('click',function(){
    
        if($('input[name=title]').val().length>0 && $('input[name=content]').val().length>0 && 
            $('input[name=url]').val().length>0 && $(".checkOn").eq(0).val()!='' && $(".i_promise").find("a").hasClass("on")){
            if ( $('#tabindex').val()>0&&$(".ridioIndex").eq(0).val()>0 && $(".checkOn").eq(1).val()!='' && $(".ridioIndex").eq(1).val()>0){
                publishLessonFn();
                //alert("进入第1种情况 是")
            } else if ($('#tabindex').val() < 1) {
                publishLessonFn();
                //alert("进入第2种情况 否")
            }else{
                alert('请完善选项')
            }
        }else{
            alert('请完善选项')
        }
    })
})
